<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="s" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>


<%
	System.out.println("------------------------------------");

	java.util.Enumeration en = request.getAttributeNames();
	
	while(en.hasMoreElements()){
		
		String name = (String)en.nextElement();
		
		System.out.println(name + ":" +request.getAttribute(name));
	}

%>

    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>



  <c:if test="${status.error}">
	<div id="message" class="error">Form has errors</div>
  </c:if>


<form:form name="form1" modelAttribute="memberVO" method="post" action="registForm">

<script>
console.log('${message}');
</script>


  <c:if test="${not empty message}">
	<div id="message" >${message}</div>
  </c:if>

<ul>
  <li>
	  <form:label path="id">ID</form:label>
	  <form:input path="id"/>
	  <form:errors path="id"></form:errors>
  </li>
  <li>
	  <form:label path="pw">PW</form:label>
	  <form:input path="pw"/>
	  <form:errors path="pw"></form:errors>
  </li>
  <li>
	  <form:label path="name">Name</form:label>
	  <form:input path="name"/>
	  <form:errors path="name"></form:errors>
  </li>
  <li>
	  <form:label path="email">EMail</form:label>
	  <form:input path="email"/>
  </li>    
  <li>
	  <form:button id="btn">REGIST</form:button>
  </li>    
</ul>
</form:form>


<script type="text/javascript" src="<c:url value="/resources/js/jquery-1.10.1.min.js" />"></script>
<script>

console.log('${memberVO}');

$('#btn').bind("click", function(event){
	
	event.preventDefault();
	
	var $form = $("#memberVO");
	
/*  	$.post($form.attr("action"), $form.serialize(), function(data){
 		
		alert(data);
		
	});  */
	$form.submit();
	
});

</script>
</body>
</html>